#include "HookLibrary.h"
#include "KeyboardProc.h"
#include "FileWatcher.h"

CRITICAL_SECTION g_csModule;
HMODULE          g_hModule = NULL;
DWORD            g_dwTlsIndex = 0;

BOOL APIENTRY DllMain(HMODULE hModule, DWORD fReason, LPCVOID lpReserved)
{
	if (fReason == DLL_PROCESS_ATTACH)
	{
		g_hModule = hModule;
		g_dwTlsIndex = TlsAlloc();

		DisableThreadLibraryCalls(g_hModule);
		InitializeCriticalSection(&g_csModule);
	}
	else if ((fReason == DLL_PROCESS_DETACH) && (lpReserved == NULL))
	{
		SetLastDeadKey(NULL);
		TlsFree(g_dwTlsIndex);

		DeleteCriticalSection(&g_csModule);
	}

	return TRUE;
}

